const path = require("path");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const { electron } = require("process");
module.exports = {
  target: "node",
  entry: "./test/main.ts",
  output: {
    path: path.resolve(__dirname, "dist2"), // 主输出目录
    filename: "[name].js",
  },
  plugins: [new NodePolyfillPlugin()],
  module: {
    rules: [
      {
        test: /\.ts$/,
        use: "ts-loader",
        exclude: /node_modules/,
      },
      {
        test: /\.js$/, // 匹配所有 .js 文件
        exclude: /node_modules/, // 排除 node_modules 文件夹
        use: {
          loader: "babel-loader",
          options: {
            // Babel 配置选项
          },
        },
      },
    ],
  },
  externals: {
    electron: 'require("electron")',
  },
  resolve: {
    extensions: [".ts", ".js"],
  },
};
